#pragma once

#include <iostream>
#include <string>
#include <fstream>

class Util
{
public:
    // XXXX XXX XXX\r\nYYYYY
    static std::string getOneLine(std::string &buffer, const std::string &sep)
    {
        auto pos = buffer.find(sep);
        if(pos == std::string::npos) return "";
        std::string sub = buffer.substr(0, pos);
        buffer.erase(0, sub.size()+sep.size());
        return sub;
    }

    static bool ReadFile(const std::string path, std::string *body)   //文本文件读取到body中
    {
        std::ifstream in(path);
        if(!in.is_open()) return false;   //统一没找到就是404
        std::string line;
        while(getline(in,line))
        {
            *body+=line;
        }
        in.close();
        return true;
    }


};